﻿using Util.Ui.NgZorro.Enums;

namespace Util.Ui.NgZorro.Components.Forms.Configs;

/// <summary>
/// 表单共享配置
/// </summary>
public class FormShareConfig {
    /// <summary>
    /// 查询表单栅格列标识
    /// </summary>
    private readonly List<string> _columnIds;

    /// <summary>
    /// 初始化表单共享配置
    /// </summary>
    public FormShareConfig() {
        _columnIds = new List<string>();
    }

    /// <summary>
    /// 表单标识
    /// </summary>
    public string FormId { get; set; }

    /// <summary>
    /// 获取查询条件数量
    /// </summary>
    public int GetConditionCount() {
        return _columnIds.Count - 1;
    }

    /// <summary>
    /// 添加查询表单栅格列标识
    /// </summary>
    /// <param name="columnId">栅格列标识</param>
    public void AddColumnId( string columnId ) {
        _columnIds.Add( columnId );
    }

    /// <summary>
    /// 是否查询表单最后一个操作栅格
    /// </summary>
    /// <param name="columnId">栅格列标识</param>
    public bool IsActionColumn( string columnId ) {
        if ( GetConditionCount() == 0 )
            return false;
        return _columnIds.LastOrDefault() == columnId;
    }

    /// <summary>
    /// 是否隐藏查询条件
    /// </summary>
    /// <param name="columnId">栅格列标识</param>
    public bool IsHide( string columnId ) {
        var index = _columnIds.FindIndex( id => id == columnId );
        if ( SearchFormShowNumber.SafeValue() == 0 )
            SearchFormShowNumber = 3;
        return index >= SearchFormShowNumber;
    }

    /// <summary>
    /// form 已创建
    /// </summary>
    public bool FormCreated { get; set; }
    /// <summary>
    /// 是否查询表单
    /// </summary>
    public bool? IsSearch { get; set; }
    /// <summary>
    /// 查询表单初始显示的查询条件数量
    /// </summary>
    public int? SearchFormShowNumber { get; set; }
    /// <summary>
    /// 查询表单每行显示几列
    /// </summary>
    public int? SearchFormColumnsNumber { get; set; }
    /// <summary>
    /// 是否显示标签
    /// </summary>
    public bool? ShowLabel { get; set; }
    /// <summary>
    /// 标签宽度
    /// </summary>
    public string LabelWidth { get; set; }
    /// <summary>
    /// 垂直对齐方式
    /// </summary>
    public Align? Align { get; set; }
    /// <summary>
    /// 垂直对齐方式
    /// </summary>
    public string BindAlign { get; set; }
    /// <summary>
    /// 栅格间隔
    /// </summary>
    public string Gutter { get; set; }
    /// <summary>
    /// 水平排列方式
    /// </summary>
    public Justify? Justify { get; set; }
    /// <summary>
    /// 水平排列方式
    /// </summary>
    public string BindJustify { get; set; }
    /// <summary>
    /// 自动设置表单标签 nzFor 属性
    /// </summary>
    public bool? AutoNzFor { get; set; }
    /// <summary>
    /// 展示校验状态图标
    /// </summary>
    public bool? HasFeedback { get; set; }
    /// <summary>
    /// 标签跨度
    /// </summary>
    public string LabelSpan { get; set; }
    /// <summary>
    /// 标签偏移量
    /// </summary>
    public string LabelOffset { get; set; }
    /// <summary>
    /// 标签栅格顺序
    /// </summary>
    public string LabelOrder { get; set; }
    /// <summary>
    /// 标签栅格左移
    /// </summary>
    public string LabelPull { get; set; }
    /// <summary>
    /// 标签栅格右移
    /// </summary>
    public string LabelPush { get; set; }
    /// <summary>
    /// 标签Flex布局
    /// </summary>
    public string LabelFlex { get; set; }
    /// <summary>
    /// 标签超窄尺寸响应式栅格
    /// </summary>
    public string LabelXs { get; set; }
    /// <summary>
    /// 标签超窄尺寸响应式栅格跨度
    /// </summary>
    public int? LabelXsSpan { get; set; }
    /// <summary>
    /// 标签超窄尺寸响应式栅格偏移量
    /// </summary>
    public int? LabelXsOffset { get; set; }
    /// <summary>
    /// 标签超窄尺寸响应式栅格顺序
    /// </summary>
    public int? LabelXsOrder { get; set; }
    /// <summary>
    /// 标签超窄尺寸响应式栅格左移
    /// </summary>
    public int? LabelXsPull { get; set; }
    /// <summary>
    /// 标签超窄尺寸响应式栅格右移
    /// </summary>
    public int? LabelXsPush { get; set; }
    /// <summary>
    /// 标签窄尺寸响应式栅格
    /// </summary>
    public string LabelSm { get; set; }
    /// <summary>
    /// 标签窄尺寸响应式栅格跨度
    /// </summary>
    public int? LabelSmSpan { get; set; }
    /// <summary>
    /// 标签窄尺寸响应式栅格偏移量
    /// </summary>
    public int? LabelSmOffset { get; set; }
    /// <summary>
    /// 标签窄尺寸响应式栅格顺序
    /// </summary>
    public int? LabelSmOrder { get; set; }
    /// <summary>
    /// 标签窄尺寸响应式栅格左移
    /// </summary>
    public int? LabelSmPull { get; set; }
    /// <summary>
    /// 标签窄尺寸响应式栅格右移
    /// </summary>
    public int? LabelSmPush { get; set; }
    /// <summary>
    /// 标签中尺寸响应式栅格
    /// </summary>
    public string LabelMd { get; set; }
    /// <summary>
    /// 标签中尺寸响应式栅格跨度
    /// </summary>
    public int? LabelMdSpan { get; set; }
    /// <summary>
    /// 标签中尺寸响应式栅格偏移量
    /// </summary>
    public int? LabelMdOffset { get; set; }
    /// <summary>
    /// 标签中尺寸响应式栅格顺序
    /// </summary>
    public int? LabelMdOrder { get; set; }
    /// <summary>
    /// 标签中尺寸响应式栅格左移
    /// </summary>
    public int? LabelMdPull { get; set; }
    /// <summary>
    /// 标签中尺寸响应式栅格右移
    /// </summary>
    public int? LabelMdPush { get; set; }
    /// <summary>
    /// 标签宽尺寸响应式栅格
    /// </summary>
    public string LabelLg { get; set; }
    /// <summary>
    /// 标签宽尺寸响应式栅格跨度
    /// </summary>
    public int? LabelLgSpan { get; set; }
    /// <summary>
    /// 标签宽尺寸响应式栅格偏移量
    /// </summary>
    public int? LabelLgOffset { get; set; }
    /// <summary>
    /// 标签宽尺寸响应式栅格顺序
    /// </summary>
    public int? LabelLgOrder { get; set; }
    /// <summary>
    /// 标签宽尺寸响应式栅格左移
    /// </summary>
    public int? LabelLgPull { get; set; }
    /// <summary>
    /// 标签宽尺寸响应式栅格右移
    /// </summary>
    public int? LabelLgPush { get; set; }
    /// <summary>
    /// 标签超宽尺寸响应式栅格
    /// </summary>
    public string LabelXl { get; set; }
    /// <summary>
    /// 标签超宽尺寸响应式栅格跨度
    /// </summary>
    public int? LabelXlSpan { get; set; }
    /// <summary>
    /// 标签超宽尺寸响应式栅格偏移量
    /// </summary>
    public int? LabelXlOffset { get; set; }
    /// <summary>
    /// 标签超宽尺寸响应式栅格顺序
    /// </summary>
    public int? LabelXlOrder { get; set; }
    /// <summary>
    /// 标签超宽尺寸响应式栅格左移
    /// </summary>
    public int? LabelXlPull { get; set; }
    /// <summary>
    /// 标签超宽尺寸响应式栅格右移
    /// </summary>
    public int? LabelXlPush { get; set; }
    /// <summary>
    /// 标签极宽尺寸响应式栅格
    /// </summary>
    public string LabelXxl { get; set; }
    /// <summary>
    /// 标签极宽尺寸响应式栅格跨度
    /// </summary>
    public int? LabelXxlSpan { get; set; }
    /// <summary>
    /// 标签极宽尺寸响应式栅格偏移量
    /// </summary>
    public int? LabelXxlOffset { get; set; }
    /// <summary>
    /// 标签极宽尺寸响应式栅格顺序
    /// </summary>
    public int? LabelXxlOrder { get; set; }
    /// <summary>
    /// 标签极宽尺寸响应式栅格左移
    /// </summary>
    public int? LabelXxlPull { get; set; }
    /// <summary>
    /// 标签极宽尺寸响应式栅格右移
    /// </summary>
    public int? LabelXxlPush { get; set; }
    /// <summary>
    /// 控件跨度
    /// </summary>
    public string ControlSpan { get; set; }
    /// <summary>
    /// 控件偏移量
    /// </summary>
    public string ControlOffset { get; set; }
    /// <summary>
    /// 控件栅格顺序
    /// </summary>
    public string ControlOrder { get; set; }
    /// <summary>
    /// 控件栅格左移
    /// </summary>
    public string ControlPull { get; set; }
    /// <summary>
    /// 控件栅格右移
    /// </summary>
    public string ControlPush { get; set; }
    /// <summary>
    /// 控件Flex布局
    /// </summary>
    public string ControlFlex { get; set; }
    /// <summary>
    /// 控件超窄尺寸响应式栅格
    /// </summary>
    public string ControlXs { get; set; }
    /// <summary>
    /// 控件超窄尺寸响应式栅格跨度
    /// </summary>
    public int? ControlXsSpan { get; set; }
    /// <summary>
    /// 控件超窄尺寸响应式栅格偏移量
    /// </summary>
    public int? ControlXsOffset { get; set; }
    /// <summary>
    /// 控件超窄尺寸响应式栅格顺序
    /// </summary>
    public int? ControlXsOrder { get; set; }
    /// <summary>
    /// 控件超窄尺寸响应式栅格左移
    /// </summary>
    public int? ControlXsPull { get; set; }
    /// <summary>
    /// 控件超窄尺寸响应式栅格右移
    /// </summary>
    public int? ControlXsPush { get; set; }
    /// <summary>
    /// 控件窄尺寸响应式栅格
    /// </summary>
    public string ControlSm { get; set; }
    /// <summary>
    /// 控件窄尺寸响应式栅格跨度
    /// </summary>
    public int? ControlSmSpan { get; set; }
    /// <summary>
    /// 控件窄尺寸响应式栅格偏移量
    /// </summary>
    public int? ControlSmOffset { get; set; }
    /// <summary>
    /// 控件窄尺寸响应式栅格顺序
    /// </summary>
    public int? ControlSmOrder { get; set; }
    /// <summary>
    /// 控件窄尺寸响应式栅格左移
    /// </summary>
    public int? ControlSmPull { get; set; }
    /// <summary>
    /// 控件窄尺寸响应式栅格右移
    /// </summary>
    public int? ControlSmPush { get; set; }
    /// <summary>
    /// 控件中尺寸响应式栅格
    /// </summary>
    public string ControlMd { get; set; }
    /// <summary>
    /// 控件中尺寸响应式栅格跨度
    /// </summary>
    public int? ControlMdSpan { get; set; }
    /// <summary>
    /// 控件中尺寸响应式栅格偏移量
    /// </summary>
    public int? ControlMdOffset { get; set; }
    /// <summary>
    /// 控件中尺寸响应式栅格顺序
    /// </summary>
    public int? ControlMdOrder { get; set; }
    /// <summary>
    /// 控件中尺寸响应式栅格左移
    /// </summary>
    public int? ControlMdPull { get; set; }
    /// <summary>
    /// 控件中尺寸响应式栅格右移
    /// </summary>
    public int? ControlMdPush { get; set; }
    /// <summary>
    /// 控件宽尺寸响应式栅格
    /// </summary>
    public string ControlLg { get; set; }
    /// <summary>
    /// 控件宽尺寸响应式栅格跨度
    /// </summary>
    public int? ControlLgSpan { get; set; }
    /// <summary>
    /// 控件宽尺寸响应式栅格偏移量
    /// </summary>
    public int? ControlLgOffset { get; set; }
    /// <summary>
    /// 控件宽尺寸响应式栅格顺序
    /// </summary>
    public int? ControlLgOrder { get; set; }
    /// <summary>
    /// 控件宽尺寸响应式栅格左移
    /// </summary>
    public int? ControlLgPull { get; set; }
    /// <summary>
    /// 控件宽尺寸响应式栅格右移
    /// </summary>
    public int? ControlLgPush { get; set; }
    /// <summary>
    /// 控件超宽尺寸响应式栅格
    /// </summary>
    public string ControlXl { get; set; }
    /// <summary>
    /// 控件超宽尺寸响应式栅格跨度
    /// </summary>
    public int? ControlXlSpan { get; set; }
    /// <summary>
    /// 控件超宽尺寸响应式栅格偏移量
    /// </summary>
    public int? ControlXlOffset { get; set; }
    /// <summary>
    /// 控件超宽尺寸响应式栅格顺序
    /// </summary>
    public int? ControlXlOrder { get; set; }
    /// <summary>
    /// 控件超宽尺寸响应式栅格左移
    /// </summary>
    public int? ControlXlPull { get; set; }
    /// <summary>
    /// 控件超宽尺寸响应式栅格右移
    /// </summary>
    public int? ControlXlPush { get; set; }
    /// <summary>
    /// 控件极宽尺寸响应式栅格
    /// </summary>
    public string ControlXxl { get; set; }
    /// <summary>
    /// 控件极宽尺寸响应式栅格跨度
    /// </summary>
    public int? ControlXxlSpan { get; set; }
    /// <summary>
    /// 控件极宽尺寸响应式栅格偏移量
    /// </summary>
    public int? ControlXxlOffset { get; set; }
    /// <summary>
    /// 控件极宽尺寸响应式栅格顺序
    /// </summary>
    public int? ControlXxlOrder { get; set; }
    /// <summary>
    /// 控件极宽尺寸响应式栅格左移
    /// </summary>
    public int? ControlXxlPull { get; set; }
    /// <summary>
    /// 控件极宽尺寸响应式栅格右移
    /// </summary>
    public int? ControlXxlPush { get; set; }
}